from __future__ import print_function

import numpy as np
import os
import cv2
from keras.preprocessing.image import ImageDataGenerator

from utils import image_utils
from utils import data_utils


def pre_train(X, y=None):
    # denoise

    for i in range(X.shape[0]):
        for j in range(0, X.shape[1]):
            X[i, j] = cv2.bilateralFilter(X[i, j], 5, 32, 32)
    if y is not None:
        pass

    X_resize = np.ndarray((X.shape[0], X.shape[1], 64, 64))
    for i in range(X.shape[0]):
        for j in range(0, X.shape[1]):
            X_resize[i, j] = image_utils.resize(X[i, j], 64)
    X = X_resize    # progbar = Progbar(X.shape[0])  # progress bar for pre-processing status tracking

    return X, y


def per_epoch(X):
    X_epoch = np.copy(X)
    X_epoch = image_utils.rotation_augmentation(X_epoch, 15)
    X_epoch = image_utils.shift_augmentation(X_epoch, 0.1, 0.1)
    return X_epoch